package com.stylefeng.symka.core.aop;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 全局的的异常拦截器（拦截所有的控制器）（带有@RequestMapping注解的方法上都会拦截）
 *
 * @author fengshuonan
 * @date 2016年11月12日 下午3:19:56
 */
@ControllerAdvice(basePackages = "com.stylefeng.symka.modular.app")
public class AppExceptionHandler {

    private Logger log = LoggerFactory.getLogger(this.getClass());



    /**
     * session异常
     *
     * @author stylefeng
     * @Date 2017/6/7 21:02
     */
    @ExceptionHandler(RuntimeException.class)
    public ModelAndView appException(Model model, HttpServletRequest request, HttpServletResponse response) {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("/login.html");
        return modelAndView;
    }


}
